﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
using System.Data.SqlClient;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// user_basic
	/// </summary>
	public partial class user_basic
	{
		private readonly lcmyjobs.DAL.user_basic dal=new lcmyjobs.DAL.user_basic();
		public user_basic()
		{}
		#region  Method
        /// <summary>
        /// 判断是否为悬赏或高级人才
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool isadvorreward(int id)
        {
            return dal.isadvorreward(id);
        }
        public int FindIDByRBH(string rbh)
        {
            return dal.FindIDByRBH(rbh);
        }
        public int FindIDByABH(string rbh)
        {
            return dal.FindIDByABH(rbh);
        }
        public DataSet FindIDByEmail(string email)
        {
            return dal.FindIDByEmail(email);
        }
        public int setResetPWDTime(string uid, string resetpwdtime)
        {
            return dal.setResetPWDTime(uid, resetpwdtime);
        }
        public DataSet getResetPWDTime(string uid)
        {
            return dal.getResetPWDTime(uid);
        }
        public int adduserhunter(int uid, int rid, out int rowa)
        {
            return dal.adduserhunter(uid, rid, out rowa);
        }
        public int adduseremp(int uid, int rid, out int rowa)
        {
            return dal.adduseremp(uid, rid, out rowa);
        }
        public int addusercollect(int uid,int rid,out int  rowa)
        {
            return dal.addusercollect(uid, rid, out rowa);
        }
        public int updateusertime(int uid)
        {
            return dal.updateusertime(uid);
        }
        public int deletebrowse(string uid)
        {
            return dal.deletebrowse(uid);
        }
        public int deleteinterview(string uid)
        {
            return dal.deleteinterview(uid);
        }
        public int deleteemps(string uid)
        {
            return dal.deleteemps(uid);
        }
         public int deleteaskhunters(string uid)
        {
            return dal.deleteaskhunters(uid);
        }
        public int deletecollects(string uid)
        {
            return dal.deletecollects(uid);
        }
        public int UserLogin(string name, string pwd, out string mname,out string datetime)
        {
            return dal.UserLogin(name, pwd,out mname, out datetime);
        }
        public int UpdateRewardTime(string uid)
        {
            return dal.UpdateRewardTime(uid);
        }
        public int UpdateAskHunterStatus(string aid, int st)
        {
            return dal.UpdateAskHunterStatus(aid, st);
        }
        public int UpdateRewardOKStatus(string uid, int st)
        {
            return dal.UpdateRewardOKStatus(uid, st);
        }
        public int UpdateRewardStatus(string uid, int st)
        {
            return dal.UpdateRewardStatus(uid, st);
        }
        public int UpdateAdvTime(string uid)
        {
            return dal.UpdateAdvTime(uid);
        }
        public int UpdateAdvOKStatus(string uid, int st)
        {
            return dal.UpdateAdvOKStatus(uid, st);
        }
        public int UpdateAdvStatus(string uid, int st)
        {
            return dal.UpdateAdvStatus(uid, st);
        }
        public DataSet GetUserJobs(int uid)
        {
            return dal.GetUserJobs(uid);
        }
         public DataSet GetAdminMain(int atid)
        {
            return dal.GetAdminMain(atid);
        }
        public DataSet GetUserMain(int uid)
        {
            return dal.GetUserMain(uid);
        }
        public DataSet GetUserEmails(string uid)
        {
            return dal.GetUserEmails(uid);
        }
        public int UpdateStatus(string uid, int st)
        {
            return dal.UpdateStatus(uid, st);
        }
        public int deleteusers(string uid)
        {
            return dal.deleteusers(uid);
        }
        public DataSet PageUserAskHunter(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserAskHunter(atid, startid, pagesize, out count);
        }
         public DataSet PageUserNew(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserNew(atid, startid, pagesize, out count);
        }
        public DataSet PageUserSearch(SqlParameter[] parameters)
        {
            return dal.PageUserSearch(parameters);
        }
        public DataSet PageUserBrowse(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserBrowse(atid, startid, pagesize, out count);
        }
         public DataSet PageUserEmp(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserEmp(atid, startid, pagesize, out count);
        }
          public DataSet PageUserInterview(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserInterview(atid, startid, pagesize, out count);
        }
         public DataSet PageUserCollect(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserCollect(atid, startid, pagesize, out count);
        }
        public DataSet PageUserSchool1(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserSchool1(atid, startid, pagesize, out count);
        }

        public DataSet PageUserSchool(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserSchool(atid, startid, pagesize, out count);
        }
        public DataSet PageUserRewardList(int atid, int startid, int pagesize, out int count)
        {
            return dal.PageUserRewardList(atid, startid, pagesize, out count);
        }
         public DataSet PageUserReward(int atid, int startid, int pagesize, out int count,out int wcount)
        {
            return dal.PageUserReward(atid, startid, pagesize, out count,out wcount);
        }
         public DataSet PageUserAdv(int atid, int startid, int pagesize, out int count,out int wcount)
        {
            return dal.PageUserAdv(atid, startid, pagesize, out count,out wcount);
        }
        public DataSet PageUserResume(int atid, int startid, int pagesize, out int count,out int wcount)
        {
            return dal.PageUserResume(atid, startid, pagesize, out count,out wcount);
        }
        public int deleteadv(int id)
        {
            return dal.deleteadv(id);
        }
        public float getadv(int id)
        {
            return dal.getadv(id);
        }
        public int updateadv(int id, float yearpay)
        {
            return dal.updateadv(id, yearpay);
        }
        public int deletereward(int id)
        {
            return dal.deletereward(id);
        }
        public float getreward(int id)
        {
            return dal.getreward(id);
        }
        public int updatereward(int id, float reward)
        {
            return dal.updatereward(id, reward);
        }
        public int changeSubscription(int id, int sub)
        {
            return dal.changeSubscription(id,sub);
        }
        public int GetSubscription(int id)
        {
            return dal.GetSubscription(id);
        }
        public int changeuserstatus(int id, int status)
        {
           return dal.changeuserstatus(id, status);
        }
        public int Getuserstatus(int id)
        {
            return dal.Getuserstatus(id);
        }
        public int changelink(int id, int status)
        {
            return dal.changelink(id, status);
        }
        public int Getuserlink(int id)
        {
            return dal.Getuserlink(id);
        }
        public int UpdatePwd(int uid, string oldpwd, string newpwd)
        {
            return dal.UpdatePwd(uid, oldpwd, newpwd);
        }
		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int uid)
		{
			return dal.Exists(uid);
		}
        public bool Exists(string name,string i)
        {
            return dal.Exists(name,i);
        }
        public int getyears(SqlParameter[] parameters)
        {
            return dal.getyears(parameters);
        }
        public void addedu(SqlParameter[] parameters)
        {
            dal.addedu(parameters);
        }
        public void addjob(SqlParameter[] parameters)
        {
            dal.addjob(parameters);
        }

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(lcmyjobs.Model.user_basic model,int webid, int types)
		{
			return dal.Add(model,webid,types);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.user_basic model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int uid)
		{
			
			return dal.Delete(uid);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string uidlist )
		{
			return dal.DeleteList(uidlist );
		}
        public DataSet GetUserBasic(int uid)
        {
            return dal.GetUserBasic(uid);
        }
        public DataSet GetUserEdu(int uid)
        {
            return dal.GetUserEdu(uid);
        }
        public DataSet GetUserJob(int uid)
        {
            return dal.GetUserJob(uid);
        }
        public DataSet GetUserResume(int uid, int eid, int isself)
        {
            return dal.GetUserResume(uid,eid,isself);
        }

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.user_basic GetModel(int uid)
		{
			
			return dal.GetModel(uid);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.user_basic GetModelByCache(int uid)
		{
			
			string CacheKey = "user_basicModel-" + uid;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(uid);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.user_basic)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.user_basic> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.user_basic> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.user_basic> modelList = new List<lcmyjobs.Model.user_basic>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.user_basic model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.user_basic();
					if(dt.Rows[n]["uid"]!=null && dt.Rows[n]["uid"].ToString()!="")
					{
						model.uid=int.Parse(dt.Rows[n]["uid"].ToString());
					}
					if(dt.Rows[n]["name"]!=null && dt.Rows[n]["name"].ToString()!="")
					{
					model.name=dt.Rows[n]["name"].ToString();
					}
					if(dt.Rows[n]["pwd"]!=null && dt.Rows[n]["pwd"].ToString()!="")
					{
					model.pwd=dt.Rows[n]["pwd"].ToString();
					}
					if(dt.Rows[n]["truename"]!=null && dt.Rows[n]["truename"].ToString()!="")
					{
					model.truename=dt.Rows[n]["truename"].ToString();
					}
					if(dt.Rows[n]["sex"]!=null && dt.Rows[n]["sex"].ToString()!="")
					{
						if((dt.Rows[n]["sex"].ToString()=="1")||(dt.Rows[n]["sex"].ToString().ToLower()=="true"))
						{
						model.sex=true;
						}
						else
						{
							model.sex=false;
						}
					}
					if(dt.Rows[n]["age"]!=null && dt.Rows[n]["age"].ToString()!="")
					{
						model.age=int.Parse(dt.Rows[n]["age"].ToString());
					}
					if(dt.Rows[n]["height"]!=null && dt.Rows[n]["height"].ToString()!="")
					{
						model.height=int.Parse(dt.Rows[n]["height"].ToString());
					}
					if(dt.Rows[n]["address"]!=null && dt.Rows[n]["address"].ToString()!="")
					{
					model.address=dt.Rows[n]["address"].ToString();
					}
					if(dt.Rows[n]["huji"]!=null && dt.Rows[n]["huji"].ToString()!="")
					{
					model.huji=dt.Rows[n]["huji"].ToString();
					}
					if(dt.Rows[n]["email"]!=null && dt.Rows[n]["email"].ToString()!="")
					{
					model.email=dt.Rows[n]["email"].ToString();
					}
					if(dt.Rows[n]["phone"]!=null && dt.Rows[n]["phone"].ToString()!="")
					{
					model.phone=dt.Rows[n]["phone"].ToString();
					}
					if(dt.Rows[n]["onlinecontact"]!=null && dt.Rows[n]["onlinecontact"].ToString()!="")
					{
					model.onlinecontact=dt.Rows[n]["onlinecontact"].ToString();
					}
					if(dt.Rows[n]["edus_id"]!=null && dt.Rows[n]["edus_id"].ToString()!="")
					{
						model.edus_id=int.Parse(dt.Rows[n]["edus_id"].ToString());
					}
					if(dt.Rows[n]["school"]!=null && dt.Rows[n]["school"].ToString()!="")
					{
					model.school=dt.Rows[n]["school"].ToString();
					}
					if(dt.Rows[n]["eduyear"]!=null && dt.Rows[n]["eduyear"].ToString()!="")
					{
					model.eduyear=dt.Rows[n]["eduyear"].ToString();
					}
					if(dt.Rows[n]["utype"]!=null && dt.Rows[n]["utype"].ToString()!="")
					{
						model.utype=int.Parse(dt.Rows[n]["utype"].ToString());
					}
					if(dt.Rows[n]["workexp_id"]!=null && dt.Rows[n]["workexp_id"].ToString()!="")
					{
						model.workexp_id=int.Parse(dt.Rows[n]["workexp_id"].ToString());
					}
					if(dt.Rows[n]["jsid"]!=null && dt.Rows[n]["jsid"].ToString()!="")
					{
						model.jsid=int.Parse(dt.Rows[n]["jsid"].ToString());
					}
					if(dt.Rows[n]["jobtime"]!=null && dt.Rows[n]["jobtime"].ToString()!="")
					{
					model.jobtime=dt.Rows[n]["jobtime"].ToString();
					}
					if(dt.Rows[n]["pay"]!=null && dt.Rows[n]["pay"].ToString()!="")
					{
						model.pay=decimal.Parse(dt.Rows[n]["pay"].ToString());
					}
					if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="")
					{
						model.status=int.Parse(dt.Rows[n]["status"].ToString());
					}
					if(dt.Rows[n]["issubscription"]!=null && dt.Rows[n]["issubscription"].ToString()!="")
					{
						if((dt.Rows[n]["issubscription"].ToString()=="1")||(dt.Rows[n]["issubscription"].ToString().ToLower()=="true"))
						{
						model.issubscription=true;
						}
						else
						{
							model.issubscription=false;
						}
					}
					if(dt.Rows[n]["isshowlink"]!=null && dt.Rows[n]["isshowlink"].ToString()!="")
					{
						if((dt.Rows[n]["isshowlink"].ToString()=="1")||(dt.Rows[n]["isshowlink"].ToString().ToLower()=="true"))
						{
						model.isshowlink=true;
						}
						else
						{
							model.isshowlink=false;
						}
					}
					if(dt.Rows[n]["loginnum"]!=null && dt.Rows[n]["loginnum"].ToString()!="")
					{
						model.loginnum=int.Parse(dt.Rows[n]["loginnum"].ToString());
					}
					if(dt.Rows[n]["todayloginnum"]!=null && dt.Rows[n]["todayloginnum"].ToString()!="")
					{
						model.todayloginnum=int.Parse(dt.Rows[n]["todayloginnum"].ToString());
					}
					if(dt.Rows[n]["logintime"]!=null && dt.Rows[n]["logintime"].ToString()!="")
					{
						model.logintime=DateTime.Parse(dt.Rows[n]["logintime"].ToString());
					}
					if(dt.Rows[n]["wantedtime"]!=null && dt.Rows[n]["wantedtime"].ToString()!="")
					{
						model.wantedtime=DateTime.Parse(dt.Rows[n]["wantedtime"].ToString());
					}
					if(dt.Rows[n]["wantedstatus"]!=null && dt.Rows[n]["wantedstatus"].ToString()!="")
					{
						if((dt.Rows[n]["wantedstatus"].ToString()=="1")||(dt.Rows[n]["wantedstatus"].ToString().ToLower()=="true"))
						{
						model.wantedstatus=true;
						}
						else
						{
							model.wantedstatus=false;
						}
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

